package es.ats.codington.festival.services;



import es.ats.codington.festival.daos.PlaceDAOImp;
import es.ats.codington.festival.domain.Place;
import es.ats.codington.festival.exceptions.ServiceException;
import es.ats.codington.festival.interfaces.services.IPlaceService;
import es.ats.codington.festival.utils.FERSDataConnection;

public class PlaceService implements IPlaceService{

	private PlaceDAOImp pdi;
	private Place p;
	

	
	public PlaceService(PlaceDAOImp pdi, Place p) {
		super();
		this.pdi = pdi;
		this.p = p;
	}
	
	public PlaceService() {
		super();
		pdi=new PlaceDAOImp();
		p=new Place();
	}
	
	


	public PlaceDAOImp getPdi() {
		return pdi;
	}


	public void setPdi(PlaceDAOImp pdi) {
		this.pdi = pdi;
	}


	public Place getP() {
		return p;
	}


	public void setP(Place p) {
		this.p = p;
	}


	@Override
	public Place getPlaceById(int placeId) throws ServiceException {
		
		FERSDataConnection fdc=pdi.getCon();
		try{
			fdc.connect();
			p=pdi.getPlaceById(placeId);
			fdc.disconnect();
			return p;
		}
		catch (Exception ex) {
			throw new ServiceException("Service getPlaceById failure:"+ex.getMessage(), ex);
		}
		
	}
	
	

}
